# 导包
import requests
import config


# 创建接口类
class ContractAPI:
    # 初始化
    def __init__(self):
        self.url_upload = config.BASE_URL + "/api/common/upload"
        self.url_insert = config.BASE_URL + "/api/contract"
        # self.url_select = config.BASE_URL + "/api/contract/list?phone={}"
        self.url_select = config.BASE_URL + "/api/contract/list"

    # 合同上传
    def upload_contract(self, token666, file_data):
        return requests.post(url=self.url_upload, headers={"Authorization": token666}, files={"file": file_data})

    # 新增合同
    def insert_contract(self, token666, test_data):
        return requests.post(url=self.url_insert, headers={"Authorization": token666}, json=test_data)

    # 查询合同列表
    def select_contract_list(self, token666, phone_number):
        # return requests.get(url=self.url_select.format(phone_number), headers={"Authorization": token666})
        return requests.get(url=self.url_select, headers={"Authorization": token666}, params={"phone": phone_number})
